#define _CRT_SECURE_NO_WARNINGS 1


#include"merge.h"

void InitSeqList(SeqList* ps)
{
	ps->a = (SeqList*)malloc(sizeof(SeqList));

	ps->size = ps->capacity = 0;
}


void DisplaySeqList(SeqList* ps)
{
	for (int i = 0; i < ps->size; i++)
	{
		printf("%d\t", ps->a[i]);
	}
}

void CheckSeqListCapacity(SeqList* ps)
{
	if (ps->size == ps->capacity)
	{
		int newcapacity = ps->capacity == 0 ? 4 : 2 * ps->capacity;

		SeqList* temp = realloc(ps->a, sizeof(SeqList) * newcapacity);

		if (temp == NULL)
		{
			printf("realloc fail\n");
			exit(-1);
		}



		ps->a = temp;
		ps->capacity = newcapacity;
	}
	
}

void SeqListPushBack(SeqList* ps, int e)
{
	CheckSeqListCapacity(ps);

	ps->a[ps->size] = e;
	ps->size++;
}

int GetSeqListElem(SeqList* ps,int i,int  e)
{
	e = ps->a[i];
	return e;
}


int LocateSeqList(SeqList* ps, int e)
{
	for (int i = 0; i < ps->size; i++)
	{
		if (ps->a[i] == e)
		{
			return 1;
		}
	}
	return 0;
}

//void MergeSeqList(SeqList*)
